package com.starbaba.base.service.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.base.common.exception.AppException;
import com.base.common.log.LogService;
import com.starbaba.base.dao.LoanManagerBaseDao;
import com.starbaba.base.service.CreditEntranceService;
import com.tuanzi.server.loan_base.model.db.credit.CreditEntrance;

public class CreditEntranceServiceImpl extends LoanManagerBaseDao implements CreditEntranceService{

	@Override
	public List<CreditEntrance> getCreditEntranceList() {
		String sql = "SELECT * FROM `credit_entrance`";
		
		List<CreditEntrance> list = new ArrayList<CreditEntrance>();
		try {
			list = getDao().list(sql, CreditEntrance.class);
		} catch (AppException e) {
			LogService.error(e);
		}
		
		return list;
	}

	@Override
	public Map<Integer, String> getCreditEntranceMap() {
		
		Map<Integer, String> map = new HashMap<Integer, String>();
		String sql = "SELECT * FROM `credit_entrance`";
		
		try {
			List<CreditEntrance> list = getDao().list(sql, CreditEntrance.class);
			if(list != null && list.size() > 0){
				
				for(CreditEntrance entrance: list){
					map.put(entrance.getId().intValue(), entrance.getEntrance_name());
				}
				
			}
			
		} catch (AppException e) {
			LogService.error(e);
		}
		
		return map;
	}


}
